package cn.jz.test.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.JdbcType;

import cn.jz.test.Model.Nullable;

public class IntNullableTypeHandler extends
		org.apache.ibatis.type.BaseTypeHandler<Nullable<Integer>> {

	@Override
	public Nullable<Integer> getNullableResult(ResultSet rs, String columnName)
			throws SQLException {
		int val=0;
		Nullable<Integer> intNull=new Nullable<Integer>();
		try{
			val= rs.getInt(columnName);
			intNull.setValue(val);
			return intNull;
		}
		 catch (Exception e){
			 
		}
		finally{}
		
		return null;
	}

	@Override
	public Nullable<Integer> getNullableResult(ResultSet rs, int columnIndex)
			throws SQLException {
		int val=0;
		Nullable<Integer> intNull=new Nullable<Integer>();
		try{
			val= rs.getInt(columnIndex);
			intNull.setValue(val);
			return intNull;
		}
		 catch (Exception e){
			 
		}
		finally{}
		
		return null;
	}

	@Override
	public Nullable<Integer> getNullableResult(CallableStatement cs, int columnIndex)
			throws SQLException {
		int val=0;
		Nullable<Integer> intNull=new Nullable<Integer>();
		try{
			val= cs.getInt(columnIndex);
			intNull.setValue(val);
			return intNull;
		}
		 catch (Exception e){
			 
		}
		finally{}
		
		return null;
	}

	@Override
	public void setNonNullParameter(PreparedStatement arg0, int arg1,
			Nullable<Integer> arg2, JdbcType arg3) throws SQLException {
		// TODO Auto-generated method stub

	}

}
